<?php defined('_JEXEC') or die('Restricted access'); // no direct access 
JHTML::_('behavior.tooltip');
jimport('joomla.filesystem.file');
$document =& JFactory::getDocument();
$lang =& JFactory::getLanguage();
?>
<?php //echo JText::_('PROPERTIES_SCROLLER'); ?>
<?php
	//get parameter
	$ScrollHeight = $params->get('ScrollHeight');
	$ScrollWidth = $params->get('ScrollWidth');
	$ScrollDirection = $params->get('ScrollDirection');
	$ScrollDelay = $params->get('ScrollDelay');
	$ScrollAmount = $params->get('ScrollAmount');
	$ImgWidth = $params->get('ImgWidth');
	$ImgHeight = $params->get('ImgHeight');	
?>

<div>
	<?php
		echo " <div style=\"padding-left:20px;*padding-left:0px;width:".$ScrollWidth."px;height:".$ScrollHeight."\">
				<marquee behavior=\"scroll\" 
                        direction=\"".$ScrollDirection."\"  
                        height=\"".$ScrollHeight."\"
                        width=\"".$ScrollWidth."\"
                        scrollamount=\"".$ScrollAmount."\"
                        scrolldelay=\"".$ScrollDelay."\"
                        truespeed=\"true\" onmouseover=\"this.stop()\" onmouseout=\"this.start()\">"; 
				
		for ($i=count( $properties ) - 1; $i >=0 ; $i--){
			$row = $properties[$i];
			//$link = JRoute::_( 'index.php?option=com_properties&amp;view=property&amp;cid='.$row->Cslug.'&amp;tid='.$row->Typeslug.'&amp;id='.$row->Pslug.'&amp;Itemid='.$this->Itemid->id);
			$link = JRoute::_( 'index.php?option=com_properties&amp;view=property&amp;id='.$row->id);
			?>
			<div>
				<?php
					if($row->image1!=NULL){ 
						$img=$row->image1;
						$destino_imagen = JPATH_SITE.DS.'images'.DS.'properties'.DS.'peques'.DS.'peque_'.$img;
						if (JFile::exists($destino_imagen)){
							$imgTag='<img src="images/properties/peques/peque_'. 
							$img .'" alt="'. str_replace('"',' ',$row->name) .'" width="'.$ImgWidth.'" height="'.$ImgHeight.'" />';
						}else{
							$img = 'noimage.jpg';
							$imgTag='<img src="images/properties/peques/peque_'. $img .'" width="'.$ImgWidth.'" height="'.$ImgHeight.'" />';
						}
					}else{
						$img = 'noimage.jpg';
						$imgTag='<img src="images/properties/peques/peque_'. $img .'" width="'.$ImgWidth.'" height="'.$ImgHeight.'" />';
					}					
				?>
				<a href="<?php echo $link; ?>"><?php echo $imgTag;?></a>				
				<a href="<?php echo $link; ?>"><br><?php echo $row->name; ?></a>
				<br/><br/><br/>
			</div>
			<?php			
		}
		
		echo "  </marquee>
             </div>";
	?>
</div>